define(['angular', 'app', 'ngUiRouter', 'app.services','services/common/base'], function (angular, app,service) {

    'use strict';

    app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {

        app.loadJs = function(js){
            return function($rootScope, $q){
                var def = $q.defer(), deps=[];
                angular.isArray(js) ? (deps = js) : deps.push(js);
                require(deps,function(){
                    $rootScope.$apply(function(){
                        def.resolve();
                    });
                });
                return def.promise;
            };
        };

            $urlRouterProvider.otherwise(function(){
                return "/login/index"
            });
            /**
             * 基础路由
             */
            $stateProvider.state("login", {
                    url: "/login",
                    templateUrl: "/app/partial/user/login_share.html"
            });

            $stateProvider.state("login.index", {
                    url: "/index",
                    resolve: {
                        deps:app.loadJs(['directives/user/login'])
                    },
                    template: "<admin-login></admin-login>"
            });

            /**
             * 基础路由
             */
            $stateProvider.state("register", {
                url: "/register",
                templateUrl: "/app/partial/user/register_share.html"
            });

            $stateProvider.state("register.index", {
                url: "/index",
                resolve: {
                    deps:app.loadJs(['directives/user/login'])
                },
                template: "<user-register></user-register>"
            });


        /**
         * 基础路由
         */
        $stateProvider.state("forgetPwd", {
            url: "/forgetPwd",
            templateUrl: "/app/partial/user/forgetPwd_share.html"
        });

        $stateProvider.state("forgetPwd.index", {
            url: "/index",
            resolve: {
                deps:app.loadJs(['directives/user/login'])
            },
            template: "<user-forget-pwd></user-forget-pwd>"
        });


        /**
         * 基础路由
         */
        $stateProvider.state("changePwd", {
            url: "/changePwd",
            templateUrl: "/app/partial/user/changePwd_share.html"
        });

        $stateProvider.state("changePwd.index", {
            url: "/index",
            resolve: {
                deps:app.loadJs(['directives/user/login'])
            },
            template: "<user-change-pwd></user-change-pwd>"
        });
    }]);
});